from flask import Flask, render_template
from flaskwebgui import FlaskUI

class App(object):

    def __init__(self, environ, start_response):
        self.environ = environ
        self.start_response = start_response
        self.html = \
        b"""
            <html>
                <head>
                    <title>Example App</title>
                </head>
                <body>
                    <h1>Example App is working!</h1>
                </body>
            </html>
        """

    def __call__(self):
        self.start_response("200 OK", [("Content-type", "text/html"),
                                        ('Content-Length', str(len(self.html)))])

        return [self.html]

# 正常实例化flask对象
app = Flask(__name__)
# 将app对象传入FlaskUI的构造函数中, 并设置要打开的窗口尺寸
ui = FlaskUI(app, width=800, height=600)

@app.route('/')
def index():
    return render_template('index.html')


if __name__ == '__main__':
	# 注意这里调用的是ui的run
    ui.run()

